package org.yinweichen.llm_dataset_backend.entity;

import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

@Data
@Entity
@Table(name = "question_tag")
@IdClass(QuestionTagId.class)
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class QuestionTag {
    @Id
    private Long id;

    @Id
    private String version;

    @Id
    private String tag;

    @ManyToOne
    @JoinColumns({
        @JoinColumn(name = "question_id", referencedColumnName = "id",  updatable = false),
        @JoinColumn(name = "question_version", referencedColumnName = "version",  updatable = false)
    })
    @OnDelete(action = OnDeleteAction.CASCADE)
    private StandardQuestion question;
}